My Matlab projects
This is a collection of some of the most interesting Matlab projects
Economics - Finance - Mathematics
Oligopoli model using game theory
Defining inputs
%Defining parameters cost functions
C_1(q)=c_11+c_12*q^2+c_13*q^3
C_1(q) = 
C_2(q)=c_21+c_22*q^2+c_23*q^3
C_2(q) = 
C_3(q)=c_31+c_32*q^2+c_33*q^3
C_3(q) =

%Defining market demand function
D(Q)=a-b*Q
D(Q) = 
Computing Marginal Profit
%Defining firm profit function
% computing marginal profit
MP_1=marginal_profit(q1,C_1,Q_tot,D)
MP_1(q1) = 
MP_2=marginal_profit(q2,C_2,Q_tot,D)
MP_2(q2) = 
MP_3=marginal_profit(q3,C_3,Q_tot,D)
MP_3(q3) =

eqs'
ans =

% Extracting the solutions
Equilibrium quantities and market quantity
% Equilibrium quantities and market distribution
Reaction functions
quantity_1(q2,q3)=solve(MP_1==0,q1)
Warning: Solutions are valid under the following conditions: q2 + q3 < 12. To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
quantity_1(q2, q3) =

quantity_2(q1,q3)=solve(MP_2==0,q2)
Warning: Solutions are valid under the following conditions: q1 + q3 < 12. To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
quantity_2(q1, q3) =

quantity_3(q1,q2)=solve(MP_3==0,q3)
Warning: Solutions are valid under the following conditions: q1 + q2 < 12. To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
quantity_3(q1, q2) =

fplot(quantity_1(q2,q_3),[0,20])
fplot(quantity_1(q_2,q3),[0,20])
title("reaction functions firm 1")
legend("q2","q3",'Location',"best")
fplot(quantity_2(q1,q_3),[0,20])
fplot(quantity_2(q_1,q3),[0,20])
title("reaction functions firm 2")
legend("q1","q3",'Location',"best")
fplot(quantity_3(q1,q_2),[0,20])
fplot(quantity_3(q_1,q2),[0,20])
title("reaction functions firm 3")
legend("q1","q2",'Location',"best")
fplot((quantity_1(q2,q_3)),[0,20])
fplot(finverse(quantity_2(q1,q_3)),[0,20])
title("reaction functions firm 1-2")
fplot(quantity_1(q_2,q3),[0,20])
fplot(finverse(quantity_3(q1,q_2)),[0,20])
title("reaction functions firm 1-3")
fplot(quantity_2(q_1,q3),[0,20])
fplot(finverse(quantity_3(q_1,q2)),[0,20])
title("reaction functions firm 2-3")
Application of Game theory
Computing Nash Equilibrium and minimax given game matrices using derivatives method and expectation method. The Jacobi derived from matching (s1,s2)-->(E(s1),E(s2)) has minimax on the opposite diagonal.
A = sym('a', [2 2])
A =

B = sym('b', [2 2])
B =

s_1=[x;1-x]
s_1 =

s_2=[y;1-y]
s_2 =

E_1=s_1.'*A*s_2
E_1 = 
E_2=s_2.'*B*s_1
E_2 = 
expand(c1)
ans = 
NE_pl2=solve(c1,y)
NE_pl2 =

expand(c2)
ans = 
NE_pl1=solve(c2,x)
NE_pl1 =

expand(c3)
ans = 
MinMaxx=solve(c3,x)
MinMaxx =

expand(c4)
ans = 
MinMaxy=solve(c4,y)
MinMaxy =

eq_1=sum(A(:,1).*s_1- A(:,2).*s_1)==0
eq_1 = 
eq_2=sum(B(:,1).*s_2-B(:,2).*s_2)==0
eq_2 = 
MiMaX=solve(eq_1,x)
MiMaX =

MiMaY=solve(eq_2,y)
MiMaY =

3x3 case
A = sym('a', [3 3])
A =

B = sym('b', [3 3])
B =

s_1=[x_1;x_2;1-x_2-x_1]
s_1 =

s_2=[y_1;y_2;1-y_1-y_2]
s_2 =

E_1=s_1.'*A*s_2
E_1 = 
E_2=s_2.'*B*s_1
E_2 = 
expand(dx1)
ans = 
expand(dx2)
ans = 
NE_pl2=solve([dx1,dx2],[y_1,y_2])
NE_pl2 =
y_1: [1×1 sym]
y_2: [1×1 sym]
NE_pl2.y_1
ans =

NE_pl2.y_2
ans =

expand(dy1)
ans = 
expand(dy2)
ans = 
NE_pl1=solve([dy1,dy2],[x_1,x_2])
NE_pl1 =
x_1: [1×1 sym]
x_2: [1×1 sym]
NE_pl1.x_1
ans =

NE_pl1.x_2
ans =

expand(dE1y1)
ans = 
expand(dE1y2)
ans = 
MM_1=solve([dE1y1,dE1y2],[x_1,x_2])
MM_1 =
x_1: [1×1 sym]
x_2: [1×1 sym]
w1=MM_1.x_1
w1 =

w2=MM_1.x_2
w2 =

expand(dE2x1)
ans = 
expand(dE2x2)
ans = 
MM_2=solve([dE2x1,dE2x2],[y_1,y_2])
MM_2 =
y_1: [1×1 sym]
y_2: [1×1 sym]
w3=MM_2.y_1
w3 =

w4=MM_2.y_2
w4 =

eq3_1=sum(A(:,1).*s_1- A(:,2).*s_1)==0
eq3_1 = 
eq3_2=sum(A(:,1).*s_1- A(:,3).*s_1)==0
eq3_2 = 
eq3_3=sum(A(:,2).*s_1- A(:,3).*s_1)==0
eq3_3 = 
S1=solve([eq3_1,eq3_2],[x_1,x_2])
S1 =
x_1: [1×1 sym]
x_2: [1×1 sym]
z1=S1.x_1
z1 =

z2=S1.x_2
z2 =

S2=solve([eq3_1,eq3_3],[x_1,x_2])
S2 =
x_1: [1×1 sym]
x_2: [1×1 sym]
z3=S2.x_1
z3 =

z4=S2.x_2
z4 =

S3=solve([eq3_2,eq3_3],[x_1,x_2])
S3 =
x_1: [1×1 sym]
x_2: [1×1 sym]
z5=S3.x_1
z5 =

z6=S3.x_2
z6 =

eq3b_1=sum(B(:,1).*s_2- B(:,2).*s_2)==0
eq3b_1 = 
eq3b_2=sum(B(:,1).*s_2- B(:,3).*s_2)==0
eq3b_2 = 
eq3b_3=sum(B(:,2).*s_2- B(:,3).*s_2)==0
eq3b_3 = 
S1b=solve([eq3b_1,eq3b_2],[y_1,y_2])
S1b =
y_1: [1×1 sym]
y_2: [1×1 sym]
Z1=S1b.y_1
Z1 =

Z2=S1b.y_2
Z2 =

S2b=solve([eq3b_1,eq3b_3],[y_1,y_2])
S2b =
y_1: [1×1 sym]
y_2: [1×1 sym]
Z3=S2b.y_1
Z3 =

Z4=S2b.y_2
Z4 =

S3b=solve([eq3b_2,eq3b_3],[y_1,y_2])
S3b =
y_1: [1×1 sym]
y_2: [1×1 sym]
Z5=S3b.y_1
Z5 =

Z6=S3b.y_2
Z6 =

Duration and analysis of change in price given change in yield
r=3.31/100 % interest rate
table(Time,CF,PV,PVt)
ans = 11×4 table
| | Time | CF | PV | PVt |
|---|
| 1 | 1 | 0 | 0 | 0 |
|---|
| 2 | 2 | 0 | 0 | 0 |
|---|
| 3 | 3 | 0 | 0 | 0 |
|---|
| 4 | 4 | 0 | 0 | 0 |
|---|
| 5 | 5 | 0 | 0 | 0 |
|---|
| 6 | 6 | 0 | 0 | 0 |
|---|
| 7 | 7 | 0 | 0 | 0 |
|---|
| 8 | 8 | 0 | 0 | 0 |
|---|
| 9 | 9 | 0 | 0 | 0 |
|---|
| 10 | 10 | 0 | 0 | 0 |
|---|
| 11 | 11 | 1000 | 9.679605072113059e+02 | 1.064756557932436e+04 |
|---|
sum_pvt=sum(PVt)
sum_pvt =
1.064756557932436e+04
modified_duration=durat/(1+r)
modified_duration =
10.647565579324365
Rates=[2.34 2.65 2.92 3.14 3.31]'./100;
B=sum(PV) %bond price
B =
1.009934409558063e+02
table(Time,Rate_p,CF,PV)
ans = 5×4 table
| | Time | Rate_p | CF | PV |
|---|
| 1 | 1 | 2.340000000000000 | 3.500000000000000 | 3.419972640218878 |
|---|
| 2 | 2 | 2.650000000000000 | 3.500000000000000 | 3.321621454258070 |
|---|
| 3 | 3 | 2.920000000000000 | 3.500000000000000 | 3.210470707425835 |
|---|
| 4 | 4 | 3.140000000000001 | 3.500000000000000 | 3.092854831143058 |
|---|
| 5 | 5 | 3.310000000000000 | 1.035000000000000e+02 | 87.948521322760485 |
|---|
PV_new=CF.*(1+Rates_shifted).^-Time;
B_new=sum(PV_new)
B_new =
1.059363552843600e+02
table(Time,Rates_shifted,CF,PV_new)
ans = 5×4 table
| | Time | Rates_shifted | CF | PV_new |
|---|
| 1 | 1 | 0.012900000000000 | 3.500000000000000 | 3.455425017277126 |
|---|
| 2 | 2 | 0.016000000000000 | 3.500000000000000 | 3.390631781263563 |
|---|
| 3 | 3 | 0.018700000000000 | 3.500000000000000 | 3.310770873777689 |
|---|
| 4 | 4 | 0.020900000000000 | 3.500000000000000 | 3.222071912521444 |
|---|
| 5 | 5 | 0.022600000000000 | 1.035000000000000e+02 | 92.557455699520162 |
|---|
%compute price elasticity
PE_factor=(CF.*Time.*(1+Rates).^-(Time+1))*(-1/B);
table(Time,Rates_shifted,CF,PV_new,PE_factor)
ans = 5×5 table
| | Time | Rates_shifted | CF | PV_new | PE_factor |
|---|
| 1 | 1 | 0.012900000000000 | 3.500000000000000 | 3.455425017277126 | -0.033089031041881 |
|---|
| 2 | 2 | 0.016000000000000 | 3.500000000000000 | 3.390631781263563 | -0.064080812484821 |
|---|
| 3 | 3 | 0.018700000000000 | 3.500000000000000 | 3.310770873777689 | -0.092661007845546 |
|---|
| 4 | 4 | 0.020900000000000 | 3.500000000000000 | 3.222071912521444 | -0.118767941963760 |
|---|
| 5 | 5 | 0.022600000000000 | 1.035000000000000e+02 | 92.557455699520162 | -4.214664561499389 |
|---|
PE=sum(PE_factor) % price elasticity
table(Time,Rate_p,CF,PV)
ans = 3×4 table
| | Time | Rate_p | CF | PV |
|---|
| 1 | 1 | 26/5 | 122/25 | 1220/263 |
|---|
| 2 | 2 | 26/5 | 122/25 | 2509/569 |
|---|
| 3 | 3 | 26/5 | 2622/25 | 35583/395 |
|---|
table(Time,CF,PV,PVt)
ans = 3×4 table
| | Time | CF | PV | PVt |
|---|
| 1 | 1 | 122/25 | 1220/263 | 1220/263 |
|---|
| 2 | 2 | 122/25 | 2509/569 | 5018/569 |
|---|
| 3 | 3 | 2622/25 | 35583/395 | 107830/399 |
|---|
durat=sum(PVt)/B
durat =
2.861930741631810
modified_duration=durat/(1+r)
modified_duration =
2.720466484440884
CX=(1/(2*B))*(1/(1+r)^2)*sum(PVtt1)
delta_y=2.1/100
delta_y =
0.021000000000000
deltaB_1st=-B*modified_duration*delta_y
deltaB_1st =
-5.663380452484362
deltaB_2nd=deltaB_1st+B*CX*delta_y^2
deltaB_2nd =
-5.440881470382044
Rates_shift=Rates+delta_y;
PV_shift=CF.*(1+Rates_shift).^-Time;
B_shift=sum(PV_shift) %bond price
B_shift =
93.683804709963070
Derivation of the Green function, a very important tool in the theory of differential equations with applications to BLS theory
% l<x<u a_11y(l)+a_12y'(l)=0 a_21y(u)+a_22y'(u)=0
p(x)=1/x^3
p(x) =

y_2=x^3
y_2 = 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
W=[y_1 y_2;diff(y_1,x) diff(y_2,x)]
W =

det(W)
ans = 
G_1=A*y_1+B*y_2
G_1 = 
G_1s=subs(G_1,x,l)
G_1s = 
G_2=C*y_1+D*y_2
G_2 = 
G_2s=subs(G_2,x,u)
G_2s = 
eq_1=M(1,1)*G_1s+M(1,2)*subs(diff(G_1,x),x,l)
eq_1 = 
eq_2=M(2,1)*G_2s+M(2,2)*subs(diff(G_2,x),x,u)
eq_2 = 
sol_1A=solve(eq_1==b_1,A)
sol_1A = 
sol_1B=solve(eq_1==b_1,B)
sol_1B = 
sol_2C=solve(eq_2==b_2,C)
sol_2C =
Empty sym: 0-by-1
sol_2D=solve(eq_2==b_2,D)
if isempty(sol_1B)==0 && isempty(sol_1A)==0
G_1n=subs(G_1,A,sol_1A) %sol in B
end
G_1n = 
end
G_2n = 
if isempty(sol_2D)==0 && isempty(sol_2C)==0
G_2n=subs(G_2,C,sol_2C) % sol in D
G_1n
G_1n = 
G_2n
G_2n = 
% Symmetrie assuming b_1=b_2=0
if isempty(sol_1B)==0 && isempty(sol_1A)==0
end
sy1 =

if isempty(sol_2D)==0 && isempty(sol_2C)==0
sy2=simplify(subs(G_2n,x,t)/D)
sy1
sy1 =

U_x=simplify(K*sy1)
U_x = 
L_t=simplify(K*sy2)
L_t = 
U_t=subs(U_x,x,t)
U_t = 
L_t
L_t = 
if isempty(sol_1B)==0 && isempty(sol_1A)==0
end
G_1nn = 
end
G_2nn = 
if isempty(sol_2D)==0 && isempty(sol_2C)==0
G_1nn
G_1nn = 
G_2nn
G_2nn = 
eqc=diff(G_2nn,x)-diff(G_1nn,x)
eqc = 
eqcc=subs(eqc,x,t)==1/p(t)
eqcc = 
solk=simplify(solve(eqcc,K)) % k should be a number
solk =

G_1final=simplify(subs(G_1nn,K,solk))
G_1final =

G_2final=simplify(subs(G_2nn,K,solk))
G_2final =

if simplify(subs(eqc,x,t))==0
disp('Error: 4th property')
Identification of parameters of the BLS equation
syms A B S a b c t sigma d alpha beta
V=A*S-B*S^2*exp(-a*t-b*t^2-c*t^3-d*t^4)
V = 
r=alpha*t+beta*t^3
r = 
V_t=diff(V,t)
V_t = 
V_S=diff(V,S)
V_S = 
V_SS=diff(V_S,S)
V_SS = 
eq=V_t+sigma^2/2*S^2*V_SS+r*S*V_S-r*V
eq =

simp=simplify(eq)
simp = 
collect(simp,t)
ans =

v=solve(V_S==0,S)
v =

subs(V,S,v(1))
ans =

simplify(subs(V,S,v(1)))
ans =

Bi-dimensional Newton method to solve system of equations
Solve: f=0, g=0
g=@(x,y)cos(x)-3*x.^2*y+2*y;
Newton_multi(f,g,[0;0],MaxI,tol)
Isoquants - Isocosts and Economy of scale
plot isoquants/isocosts and cost function/marginal costs/ average costs given a production function f and W wage R rental rate
a=0.25;%parameters of production function
disp('Wage W; Rental rate R');
w0=[1 1]%choose values for parameters wage(W) and rental rate(R)
disp('Production function');
f(x,y)=A.*(x.^a).*(y.^b)%production function (Cobb-Douglas type)
f(x, y) = 
disp('Cost function expressed through labour(x) and capital(y)');
Cost function expressed through labour(x) and capital(y)
cost(x,y)=W.*x+R.*y %cost function
cost(x, y) = 
[solx,soly] = solve(MPL.*R == W.*MPK, x.*W+y.*R == C);
Warning: Possibly spurious solutions.
q=(f(solx,soly));%it expresses labour(x) and capital trough Cost variable C
disp('Quantity respect to costs, wage and rental rate');
Quantity respect to costs, wage and rental rate
q=q(1)%%
q =

COST=subs(cost,[W R],w0);
q=subs(q,[W R],w0)
q =

%COST=matlabFunction(COST);
Quantity=subs(q,C,Cost); %correspondent output q(Cost)
fimplicit(F-Quantity,[0 Cost]);%isoquant at quantity q(Cost)
fimplicit(COST-Cost,[0 Cost]);%isocost
[rootx,rooty]=(solve(F-Quantity,COST-Cost));%point of production is the
%intersection between isoquant and isocost
plot(real(rootx),real(rooty),'or')
title('isoquants and isocost lines');
ExplicitCost=finverse(q);
Warning: Possibly spurious solutions.
subs(ExplicitCost,C,Q)
ans =

MarginalCost=diff(ExplicitCost);
subs(MarginalCost,C,Q)
ans =

AverageCost=ExplicitCost./C;
subs(AverageCost,C,Q)
ans =

fplot(ExplicitCost,[0 10]);
fplot(MarginalCost,[0 10]);
fplot(AverageCost,[0 10]);
legend('Cost function','Marginal Cost','Average Costs','Location','northwest');
Econometrics analysis between access to banking services and gpd growth for emerging economies
data=DataExtractFromWorldDevelopmentIndicators5;
%data=DataExtractFromWorldDevelopmentIndicators6;
head(data)
ans = 8×29 table
| | CountryName | CountryCode | SeriesName | SeriesCode | YR1996 | YR1997 | YR1998 | YR1999 | YR2000 | YR2001 | YR2002 | YR2003 | YR2004 | YR2005 | YR2006 | YR2007 | YR2008 | YR2009 | YR2010 | YR2011 | YR2012 | YR2013 | YR2014 | YR2015 | YR2016 | YR2017 | YR2018 | YR2019 | YR2020 |
|---|
| 1 | Argentina | ARG | Inflation, GDP deflator (annual %) | NY.GDP.DEFL.KD.ZG | -183/3494 | -1067/2300 | -1163/682 | -854/465 | 306/295 | -492/449 | 9686/317 | 3663/349 | 5913/322 | 3477/337 | 6527/475 | 4228/283 | 2572/111 | 2891/188 | 5668/271 | 4077/172 | 6449/289 | 7951/332 | 16798/417 | 1329/50 | 2755/67 | 3485/134 | 13147/323 | 6181/120 | .. |
|---|
| 2 | Argentina | ARG | Domestic credit to private sector by banks (% of GDP) | FD.AST.PRVT.GD.ZS | 2405/121 | 10412/483 | 13093/555 | 4079/169 | 5120/221 | 2842/141 | 4051/268 | 5215/491 | 3696/389 | 3323/319 | 5697/494 | 7643/606 | 10073/852 | 16703/1392 | 529/43 | 3859/285 | 4774/325 | 4161/274 | 3865/287 | 2253/160 | 3465/262 | 5745/373 | 0/0 | 0/0 | .. |
|---|
| 3 | Argentina | ARG | GDP per capita growth (annual %) | NY.GDP.PCAP.KD.ZG | 1868/437 | 1675/244 | 563/210 | -1987/446 | -2683/1431 | -2059/378 | -2857/241 | 3109/405 | 3769/478 | 1600/207 | 18933/2722 | 523/66 | 1336/441 | -2351/343 | 7282/783 | 1269/265 | -1137/530 | 1977/1562 | -2573/719 | 1747/1072 | -989/318 | 1075/668 | -2604/751 | -2479/792 | .. |
|---|
| 4 | Argentina | ARG | GDP per capita, PPP (constant 2017 international $) | NY.GDP.PCAP.PP.KD | 126734/7 | 135434/7 | 99332/5 | 56944/3 | 204880/11 | 193720/11 | 93139/6 | 83574/5 | 234426/13 | 97133/5 | 124667/6 | 67273/3 | 69311/3 | 258241/12 | 493951/21 | 147887/6 | 313548/13 | 73273/3 | 306154/13 | 239341/10 | 92759/4 | 282755/12 | 227459/10 | 396611/18 | .. |
|---|
| 5 | Argentina | ARG | General government final consumption expenditure (% of GDP) | NE.CON.GOVT.ZS | 3738/299 | 1556/129 | 3586/287 | 1537/112 | 4535/329 | 18389/1299 | 15343/1254 | 2585/226 | 4557/410 | 5221/430 | 2113/170 | 3650/281 | 2604/191 | 6123/385 | 3427/226 | 5397/344 | 9671/581 | 2689/160 | 6763/399 | 15637/864 | 10222/579 | 10264/581 | 5515/343 | 2398/157 | .. |
|---|
| 6 | Argentina | ARG | School enrollment, secondary (% net) | SE.SEC.NENR | 0/0 | 0/0 | 1637/22 | 4881/64 | 3218/41 | 9395/119 | 7487/95 | 14368/183 | 3220/41 | 13171/169 | 10193/131 | 5671/73 | 3854/49 | 1853/23 | 9934/121 | 12612/151 | 4037/47 | 3571/41 | 10253/117 | 7429/84 | 2337/26 | 13801/152 | 0/0 | 0/0 | .. |
|---|
| 7 | Argentina | ARG | Trade (% of GDP) | NE.TRD.GNFS.ZS | 11635/541 | 8191/351 | 41960/1797 | 9665/452 | 2217/98 | 1923/88 | 3883/93 | 3089/76 | 9400/231 | 3163/78 | 9421/233 | 2989/73 | 6020/149 | 1192/35 | 2413/69 | 3415/97 | 6899/226 | 16427/560 | 1676/59 | 2451/109 | 5558/213 | 7567/300 | 6969/227 | 7159/221 | .. |
|---|
| 8 | Brazil | BRA | Inflation, GDP deflator (annual %) | NY.GDP.DEFL.KD.ZG | 4153/225 | 5619/727 | 5013/1018 | 3052/381 | 185/33 | 2229/271 | 3106/317 | 11456/813 | 938/121 | 1999/269 | 2791/412 | 11513/1788 | 3766/429 | 2333/319 | 3681/437 | 3943/474 | 699/88 | 1651/220 | 1075/137 | 1029/136 | 1799/222 | 2277/626 | 1715/522 | 2235/538 | .. |
|---|
categories(data.SeriesName)
'Domestic credit to private …
'GDP per capita growth (annu…
'GDP per capita, PPP (consta…
'General government final co…
'Inflation, GDP deflator (an…
'School enrollment, secondar…
'Trade (% of GDP)'
country=categories(data.CountryName)
'Argentina'
'Brazil'
'Chile'
'Colombia'
'Dominican Republic'
'Egypt, Arab Rep.'
'Indonesia'
'Israel'
'Korea, Rep.'
'Malaysia'
country_abb=categories(data.CountryCode)
'ARE'
'ARG'
'BRA'
'CHL'
'COL'
'DOM'
'EGY'
'IDN'
'ISR'
'KOR'
table{i}=data(1+(i-1)*7:7*i,:);
table{i}.Properties.VariableNames{1}=country{i};
variables=table{1}.Argentina;
variables
Inflation, GDP deflator (ann…
Domestic credit to private s…
GDP per capita growth (annua…
GDP per capita, PPP (constan…
General government final con…
School enrollment, secondary…
Trade (% of GDP)
table{20}
ans = 7×21 table
| | Uruguay | YR2000 | YR2001 | YR2002 | YR2003 | YR2004 | YR2005 | YR2006 | YR2007 | YR2008 | YR2009 | YR2010 | YR2011 | YR2012 | YR2013 | YR2014 | YR2015 | YR2016 | YR2017 | YR2018 | YR2019 |
|---|
| 1 | Inflation, GDP deflator (annual %) | 2210/627 | 412/905 | 295/2706 | 1259/698 | 4703/749 | 1412/403 | 245/32 | 1279/858 | 1549/1404 | 3337/1617 | 2981/522 | 4803/712 | 4001/3327 | 665/629 | 7633/3138 | 1391/517 | 419/136 | 1016/281 | 621/308 | 6919/4448 |
|---|
| 2 | Domestic credit to private sector by banks (% of GDP) | 3161/120 | 8535/364 | 8681/391 | 12611/631 | 11373/635 | 5167/271 | 7909/380 | 12525/509 | 6935/233 | 12396/413 | 3238/107 | 4911/152 | 5447/160 | 21010/557 | 4703/115 | 7501/171 | 2911/68 | 3393/80 | 4929/112 | 4187/93 |
|---|
| 3 | GDP per capita growth (annual %) | 979/807 | -708/1079 | 1913/447 | 3941/1258 | 5137/1284 | 4381/817 | 1365/206 | 5626/737 | 3292/399 | 424/1477 | 835/112 | 8633/1579 | 2855/542 | 3623/739 | 1213/929 | 1231/627 | 1587/655 | 951/1147 | 2199/997 | 1005/1961 |
|---|
| 4 | GDP per capita, PPP (constant 2017 international $) | 160562/25 | 19141/3 | 33267/5 | 41171/6 | 99909/14 | 270685/36 | 32069/4 | 163956/19 | 121436/13 | 196729/21 | 171130/17 | 63701/6 | 122937/11 | 11724 | 142525/12 | 181654/15 | 198459/16 | 212611/17 | 102259/8 | 115631/9 |
|---|
| 5 | General government final consumption expenditure (% of GDP) | 1855/162 | 1160/99 | 4533/406 | 2154/187 | 2240/199 | 18769/1640 | 31975/2929 | 1976/189 | 1566/151 | 2385/208 | 3463/329 | 4404/425 | 1435/132 | 6176/537 | 4750/383 | 7909/610 | 4423/336 | 2801/212 | 3815/291 | 1091/82 |
|---|
| 6 | School enrollment, secondary (% net) | 12277/198 | 20216/311 | 10739/163 | 0/0 | 7990/121 | 4369/65 | 13389/193 | 6778/93 | 6721/90 | 9404/121 | 3186/41 | 7656/97 | 9189/122 | 11599/145 | 1511/19 | 18766/237 | 12421/150 | 15063/176 | 10092/113 | 0/0 |
|---|
| 7 | Trade (% of GDP) | 6539/184 | 10344/295 | 10751/305 | 11927/317 | 9184/219 | 19085/403 | 5541/107 | 6070/109 | 4850/83 | 6447/134 | 11213/217 | 4759/85 | 8998/171 | 12397/249 | 8293/177 | 1942/43 | 52878/1165 | 1758/37 | 9636/197 | 18943/402 |
|---|
table{5}
ans = 7×21 table
| | Dominican Republic | YR2000 | YR2001 | YR2002 | YR2003 | YR2004 | YR2005 | YR2006 | YR2007 | YR2008 | YR2009 | YR2010 | YR2011 | YR2012 | YR2013 | YR2014 | YR2015 | YR2016 | YR2017 | YR2018 | YR2019 |
|---|
| 1 | Inflation, GDP deflator (annual %) | 7327/657 | 1456/241 | 3269/594 | 2969/735 | 3535/444 | 2050/349 | 1067/167 | 741/128 | 2111/342 | 2112/535 | 1359/299 | 5206/891 | 6229/1532 | 283/185 | 1933/437 | 2609/936 | 242/45 | 2350/353 | 5399/1087 | 3223/967 |
|---|
| 2 | Domestic credit to private sector by banks (% of GDP) | 6074/431 | 1765/152 | 5974/453 | 2871/214 | 14419/1127 | 4161/299 | 2111/129 | 1873/105 | 7086/419 | 14219/788 | 9368/511 | 1184/61 | 6233/313 | 3951/178 | 31609/1441 | 5471/229 | 4692/181 | 7991/297 | 2791/104 | 8087/281 |
|---|
| 3 | GDP per capita growth (annual %) | 2653/771 | -2476/1381 | -2775/1978 | 130/1799 | 2173/871 | 773/889 | 767/257 | 835/1067 | -417/1166 | -7415/1111 | 463/128 | 902/405 | 2755/1226 | 23/781 | 925/617 | 723/359 | 1977/1177 | 662/707 | 2705/2727 | -2438/1983 |
|---|
| 4 | GDP per capita, PPP (constant 2017 international $) | 142265/8 | 122250/7 | 120535/7 | 120622/7 | 141293/8 | 89076/5 | 146775/8 | 203395/11 | 55273/3 | 51584/3 | 142533/8 | 127494/7 | 130359/7 | 93141/5 | 245797/13 | 77153/4 | 254959/13 | 158367/8 | 79969/4 | 138225/7 |
|---|
| 5 | General government final consumption expenditure (% of GDP) | 4377/460 | 1413/143 | 3819/368 | 1633/148 | 2475/236 | 14057/1336 | 5286/511 | 11602/1115 | 1309/122 | 3301/277 | 5097/433 | 5653/480 | 2019/169 | 2548/209 | 7541/618 | 3391/275 | 709/59 | 2128/183 | 3733/320 | 2356/203 |
|---|
| 6 | School enrollment, secondary (% net) | 13406/239 | 0/0 | 8579/142 | 9173/145 | 31795/488 | 8068/121 | 10922/161 | 7376/107 | 7030/101 | 7456/107 | 4135/59 | 2049/29 | 5387/75 | 5970/79 | 6213/80 | 18646/233 | 16407/202 | 8846/109 | 0/0 | 0/0 |
|---|
| 7 | Trade (% of GDP) | 5453/104 | 13348/283 | 4483/96 | 7079/141 | 21617/370 | 11287/181 | 8470/151 | 7213/127 | 8551/148 | 1735/31 | 7352/121 | 4189/66 | 7629/116 | 22509/353 | 3573/55 | 33804/475 | 27320/359 | 7951/103 | 2333/29 | 9772/125 |
|---|
table{i}.Average=mean(T{:,2:end},2,'omitnan');
table{i}.Average(4)=table{i}.YR2000(4);
table{1}
ans = 7×22 table
| | Argentina | YR2000 | YR2001 | YR2002 | YR2003 | YR2004 | YR2005 | YR2006 | YR2007 | YR2008 | YR2009 | YR2010 | YR2011 | YR2012 | YR2013 | YR2014 | YR2015 | YR2016 | YR2017 | YR2018 | YR2019 | Average |
|---|
| 1 | Inflation, GDP deflator (annual %) | 306/295 | -492/449 | 9686/317 | 3663/349 | 5913/322 | 3477/337 | 6527/475 | 4228/283 | 2572/111 | 2891/188 | 5668/271 | 4077/172 | 6449/289 | 7951/332 | 16798/417 | 1329/50 | 2755/67 | 3485/134 | 13147/323 | 6181/120 | 3246/143 |
|---|
| 2 | Domestic credit to private sector by banks (% of GDP) | 5120/221 | 2842/141 | 4051/268 | 5215/491 | 3696/389 | 3323/319 | 5697/494 | 7643/606 | 10073/852 | 16703/1392 | 529/43 | 3859/285 | 4774/325 | 4161/274 | 3865/287 | 2253/160 | 3465/262 | 5745/373 | 0/0 | 0/0 | 3857/279 |
|---|
| 3 | GDP per capita growth (annual %) | -2683/1431 | -2059/378 | -2857/241 | 3109/405 | 3769/478 | 1600/207 | 18933/2722 | 523/66 | 1336/441 | -2351/343 | 7282/783 | 1269/265 | -1137/530 | 1977/1562 | -2573/719 | 1747/1072 | -989/318 | 1075/668 | -2604/751 | -2479/792 | 747/815 |
|---|
| 4 | GDP per capita, PPP (constant 2017 international $) | 204880/11 | 193720/11 | 93139/6 | 83574/5 | 234426/13 | 97133/5 | 124667/6 | 67273/3 | 69311/3 | 258241/12 | 493951/21 | 147887/6 | 313548/13 | 73273/3 | 306154/13 | 239341/10 | 92759/4 | 282755/12 | 227459/10 | 396611/18 | 204880/11 |
|---|
| 5 | General government final consumption expenditure (% of GDP) | 4535/329 | 18389/1299 | 15343/1254 | 2585/226 | 4557/410 | 5221/430 | 2113/170 | 3650/281 | 2604/191 | 6123/385 | 3427/226 | 5397/344 | 9671/581 | 2689/160 | 6763/399 | 15637/864 | 10222/579 | 10264/581 | 5515/343 | 2398/157 | 3210/217 |
|---|
| 6 | School enrollment, secondary (% net) | 3218/41 | 9395/119 | 7487/95 | 14368/183 | 3220/41 | 13171/169 | 10193/131 | 5671/73 | 3854/49 | 1853/23 | 9934/121 | 12612/151 | 4037/47 | 3571/41 | 10253/117 | 7429/84 | 2337/26 | 13801/152 | 0/0 | 0/0 | 5020/61 |
|---|
| 7 | Trade (% of GDP) | 2217/98 | 1923/88 | 3883/93 | 3089/76 | 9400/231 | 3163/78 | 9421/233 | 2989/73 | 6020/149 | 1192/35 | 2413/69 | 3415/97 | 6899/226 | 16427/560 | 1676/59 | 2451/109 | 5558/213 | 7567/300 | 6969/227 | 7159/221 | 6560/199 |
|---|
table{5}
ans = 7×22 table
| | Dominican Republic | YR2000 | YR2001 | YR2002 | YR2003 | YR2004 | YR2005 | YR2006 | YR2007 | YR2008 | YR2009 | YR2010 | YR2011 | YR2012 | YR2013 | YR2014 | YR2015 | YR2016 | YR2017 | YR2018 | YR2019 | Average |
|---|
| 1 | Inflation, GDP deflator (annual %) | 7327/657 | 1456/241 | 3269/594 | 2969/735 | 3535/444 | 2050/349 | 1067/167 | 741/128 | 2111/342 | 2112/535 | 1359/299 | 5206/891 | 6229/1532 | 283/185 | 1933/437 | 2609/936 | 242/45 | 2350/353 | 5399/1087 | 3223/967 | 133/25 |
|---|
| 2 | Domestic credit to private sector by banks (% of GDP) | 6074/431 | 1765/152 | 5974/453 | 2871/214 | 14419/1127 | 4161/299 | 2111/129 | 1873/105 | 7086/419 | 14219/788 | 9368/511 | 1184/61 | 6233/313 | 3951/178 | 31609/1441 | 5471/229 | 4692/181 | 7991/297 | 2791/104 | 8087/281 | 2160/113 |
|---|
| 3 | GDP per capita growth (annual %) | 2653/771 | -2476/1381 | -2775/1978 | 130/1799 | 2173/871 | 773/889 | 767/257 | 835/1067 | -417/1166 | -7415/1111 | 463/128 | 902/405 | 2755/1226 | 23/781 | 925/617 | 723/359 | 1977/1177 | 662/707 | 2705/2727 | -2438/1983 | 1777/2463 |
|---|
| 4 | GDP per capita, PPP (constant 2017 international $) | 142265/8 | 122250/7 | 120535/7 | 120622/7 | 141293/8 | 89076/5 | 146775/8 | 203395/11 | 55273/3 | 51584/3 | 142533/8 | 127494/7 | 130359/7 | 93141/5 | 245797/13 | 77153/4 | 254959/13 | 158367/8 | 79969/4 | 138225/7 | 142265/8 |
|---|
| 5 | General government final consumption expenditure (% of GDP) | 4377/460 | 1413/143 | 3819/368 | 1633/148 | 2475/236 | 14057/1336 | 5286/511 | 11602/1115 | 1309/122 | 3301/277 | 5097/433 | 5653/480 | 2019/169 | 2548/209 | 7541/618 | 3391/275 | 709/59 | 2128/183 | 3733/320 | 2356/203 | 5003/446 |
|---|
| 6 | School enrollment, secondary (% net) | 13406/239 | 0/0 | 8579/142 | 9173/145 | 31795/488 | 8068/121 | 10922/161 | 7376/107 | 7030/101 | 7456/107 | 4135/59 | 2049/29 | 5387/75 | 5970/79 | 6213/80 | 18646/233 | 16407/202 | 8846/109 | 0/0 | 0/0 | 28349/403 |
|---|
| 7 | Trade (% of GDP) | 5453/104 | 13348/283 | 4483/96 | 7079/141 | 21617/370 | 11287/181 | 8470/151 | 7213/127 | 8551/148 | 1735/31 | 7352/121 | 4189/66 | 7629/116 | 22509/353 | 3573/55 | 33804/475 | 27320/359 | 7951/103 | 2333/29 | 9772/125 | 11959/192 |
|---|
table{20}
ans = 7×22 table
| | Uruguay | YR2000 | YR2001 | YR2002 | YR2003 | YR2004 | YR2005 | YR2006 | YR2007 | YR2008 | YR2009 | YR2010 | YR2011 | YR2012 | YR2013 | YR2014 | YR2015 | YR2016 | YR2017 | YR2018 | YR2019 | Average |
|---|
| 1 | Inflation, GDP deflator (annual %) | 2210/627 | 412/905 | 295/2706 | 1259/698 | 4703/749 | 1412/403 | 245/32 | 1279/858 | 1549/1404 | 3337/1617 | 2981/522 | 4803/712 | 4001/3327 | 665/629 | 7633/3138 | 1391/517 | 419/136 | 1016/281 | 621/308 | 6919/4448 | 1618/557 |
|---|
| 2 | Domestic credit to private sector by banks (% of GDP) | 3161/120 | 8535/364 | 8681/391 | 12611/631 | 11373/635 | 5167/271 | 7909/380 | 12525/509 | 6935/233 | 12396/413 | 3238/107 | 4911/152 | 5447/160 | 21010/557 | 4703/115 | 7501/171 | 2911/68 | 3393/80 | 4929/112 | 4187/93 | 251/8 |
|---|
| 3 | GDP per capita growth (annual %) | 979/807 | -708/1079 | 1913/447 | 3941/1258 | 5137/1284 | 4381/817 | 1365/206 | 5626/737 | 3292/399 | 424/1477 | 835/112 | 8633/1579 | 2855/542 | 3623/739 | 1213/929 | 1231/627 | 1587/655 | 951/1147 | 2199/997 | 1005/1961 | 1192/329 |
|---|
| 4 | GDP per capita, PPP (constant 2017 international $) | 160562/25 | 19141/3 | 33267/5 | 41171/6 | 99909/14 | 270685/36 | 32069/4 | 163956/19 | 121436/13 | 196729/21 | 171130/17 | 63701/6 | 122937/11 | 11724 | 142525/12 | 181654/15 | 198459/16 | 212611/17 | 102259/8 | 115631/9 | 160562/25 |
|---|
| 5 | General government final consumption expenditure (% of GDP) | 1855/162 | 1160/99 | 4533/406 | 2154/187 | 2240/199 | 18769/1640 | 31975/2929 | 1976/189 | 1566/151 | 2385/208 | 3463/329 | 4404/425 | 1435/132 | 6176/537 | 4750/383 | 7909/610 | 4423/336 | 2801/212 | 3815/291 | 1091/82 | 3043/261 |
|---|
| 6 | School enrollment, secondary (% net) | 12277/198 | 20216/311 | 10739/163 | 0/0 | 7990/121 | 4369/65 | 13389/193 | 6778/93 | 6721/90 | 9404/121 | 3186/41 | 7656/97 | 9189/122 | 11599/145 | 1511/19 | 18766/237 | 12421/150 | 15063/176 | 10092/113 | 0/0 | 11093/148 |
|---|
| 7 | Trade (% of GDP) | 6539/184 | 10344/295 | 10751/305 | 11927/317 | 9184/219 | 19085/403 | 5541/107 | 6070/109 | 4850/83 | 6447/134 | 11213/217 | 4759/85 | 8998/171 | 12397/249 | 8293/177 | 1942/43 | 52878/1165 | 1758/37 | 9636/197 | 18943/402 | 6424/137 |
|---|
Mtable.Properties.VariableNames=vars;
Mtable.Properties.RowNames=cellstr(country);
Mtable
Mtable = 20×7 table
| | Inflation, GDP deflator (annual %) | Domestic credit to private sector by banks (% of GDP) | GDP per capita growth (annual %) | General government final consumption expenditure (% of GDP) | School enrollment, secondary (% net) | Trade (% of GDP) | GDP per capita, PPP (constant 2017 international $) |
|---|
| 1 Argentina | 3246/143 | 3857/279 | 747/815 | 3210/217 | 5020/61 | 6560/199 | 204880/11 |
|---|
| 2 Brazil | 961/129 | 1496/31 | 2956/2179 | 4070/211 | 5808/73 | 2882/111 | 81180/7 |
|---|
| 3 Chile | 9377/1079 | 2937/109 | 26875/6891 | 4152/481 | 8451/131 | 10665/206 | 130853/23 |
|---|
| 4 Colombia | 563/297 | 24203/194 | 9608/2697 | 3471/248 | 28111/295 | 23511/296 | 206893/9 |
|---|
| 5 Dominican Republic | 133/25 | 2160/113 | 1777/2463 | 5003/446 | 28349/403 | 11959/192 | 142265/8 |
|---|
| 6 Egypt, Arab Rep. | 6081/463 | 11042/277 | 854/229 | 2847/160 | 23780/259 | 22305/424 | 160761/11 |
|---|
| 7 Indonesia | 601/116 | 2116/55 | 693/884 | 841/36 | 12957/148 | 26712/349 | 209776/5 |
|---|
| 8 Israel | 3758/243 | 1389/35 | 1577/466 | 1559/113 | 94605/1193 | 8843/178 | 92819/6 |
|---|
| 9 Korea, Rep. | 1415/717 | 983/14 | 1477/1012 | 5264/223 | 16342/165 | 15100/219 | 726065/23 |
|---|
| 10 Malaysia | 689/210 | 3332/29 | 6551/2005 | 15555/1256 | 5967/79 | 18272/109 | 318401/20 |
|---|
| 11 Mexico | 9167/1950 | 12021/169 | 899/344 | 5362/439 | 15775/182 | 6769/103 | 75609/5 |
|---|
| 12 Panama | 827/130 | 8201/241 | 13638/5455 | 2153/147 | 9521/129 | 9272/253 | 210074/23 |
|---|
| 13 Peru | 3557/335 | 4231/109 | 2125/907 | 4699/410 | 21815/271 | 9017/188 | 54213/7 |
|---|
| 14 Russian Federation | 14996/11397 | 14441/135 | 1360/421 | 578/57 | 7873/79 | 17931/49 | 392074/7 |
|---|
| 15 Saudi Arabia | 1533/230 | 4501/66 | 1027/839 | 1853/94 | 50669/754 | 31347/532 | 70622/7 |
|---|
| 16 Singapore | 1929/250 | 6368/207 | 257/107 | 1635/127 | 6788/89 | 12935/261 | 132961/10 |
|---|
| 17 South Africa | 2955/664 | 8617/145 | -2017/1192 | 1996/197 | 12231/136 | 9881/69 | 819959/8 |
|---|
| 18 Turkey | 5135/1766 | 8392/109 | 419/104 | 2177/174 | 6107/95 | 16330/127 | 159616/11 |
|---|
| 19 United Arab Emirates | 2046/233 | 6616/275 | 2476/677 | 21827/2240 | 21137/344 | 2825/46 | 65255/7 |
|---|
| 20 Uruguay | 1618/557 | 251/8 | 1192/329 | 3043/261 | 11093/148 | 6424/137 | 160562/25 |
|---|
new_name=["INF","BNK","GRO","GOV","SSE","TRD","INIT"];
Warning: Table variable names were truncated to the length namelengthmax.
MMT.Properties.VariableNames=new_name;
MMT
MMT = 20×7 table
| | INF | BNK | GRO | GOV | SSE | TRD | INIT |
|---|
| 1 Argentina | 3246/143 | 3857/279 | 747/815 | 3210/217 | 5020/61 | 6560/199 | 204880/11 |
|---|
| 2 Brazil | 961/129 | 1496/31 | 2956/2179 | 4070/211 | 5808/73 | 2882/111 | 81180/7 |
|---|
| 3 Chile | 9377/1079 | 2937/109 | 26875/6891 | 4152/481 | 8451/131 | 10665/206 | 130853/23 |
|---|
| 4 Colombia | 563/297 | 24203/194 | 9608/2697 | 3471/248 | 28111/295 | 23511/296 | 206893/9 |
|---|
| 5 Dominican Republic | 133/25 | 2160/113 | 1777/2463 | 5003/446 | 28349/403 | 11959/192 | 142265/8 |
|---|
| 6 Egypt, Arab Rep. | 6081/463 | 11042/277 | 854/229 | 2847/160 | 23780/259 | 22305/424 | 160761/11 |
|---|
| 7 Indonesia | 601/116 | 2116/55 | 693/884 | 841/36 | 12957/148 | 26712/349 | 209776/5 |
|---|
| 8 Israel | 3758/243 | 1389/35 | 1577/466 | 1559/113 | 94605/1193 | 8843/178 | 92819/6 |
|---|
| 9 Korea, Rep. | 1415/717 | 983/14 | 1477/1012 | 5264/223 | 16342/165 | 15100/219 | 726065/23 |
|---|
| 10 Malaysia | 689/210 | 3332/29 | 6551/2005 | 15555/1256 | 5967/79 | 18272/109 | 318401/20 |
|---|
| 11 Mexico | 9167/1950 | 12021/169 | 899/344 | 5362/439 | 15775/182 | 6769/103 | 75609/5 |
|---|
| 12 Panama | 827/130 | 8201/241 | 13638/5455 | 2153/147 | 9521/129 | 9272/253 | 210074/23 |
|---|
| 13 Peru | 3557/335 | 4231/109 | 2125/907 | 4699/410 | 21815/271 | 9017/188 | 54213/7 |
|---|
| 14 Russian Federation | 14996/11397 | 14441/135 | 1360/421 | 578/57 | 7873/79 | 17931/49 | 392074/7 |
|---|
| 15 Saudi Arabia | 1533/230 | 4501/66 | 1027/839 | 1853/94 | 50669/754 | 31347/532 | 70622/7 |
|---|
| 16 Singapore | 1929/250 | 6368/207 | 257/107 | 1635/127 | 6788/89 | 12935/261 | 132961/10 |
|---|
| 17 South Africa | 2955/664 | 8617/145 | -2017/1192 | 1996/197 | 12231/136 | 9881/69 | 819959/8 |
|---|
| 18 Turkey | 5135/1766 | 8392/109 | 419/104 | 2177/174 | 6107/95 | 16330/127 | 159616/11 |
|---|
| 19 United Arab Emirates | 2046/233 | 6616/275 | 2476/677 | 21827/2240 | 21137/344 | 2825/46 | 65255/7 |
|---|
| 20 Uruguay | 1618/557 | 251/8 | 1192/329 | 3043/261 | 11093/148 | 6424/137 | 160562/25 |
|---|
corr(M)
ans =
1 -402/665 -179/3548 77/8220 -527/3529 -281/622 -365/1372
-402/665 1 264/1357 191/7877 1359/3133 821/1313 495/1846
-179/3548 264/1357 1 -367/1261 -309/1331 707/9665 -877/1393
77/8220 191/7877 -367/1261 1 260/753 -603/2123 -45/1514
-527/3529 1359/3133 -309/1331 260/753 1 466/1263 577/1061
-281/622 821/1313 707/9665 -603/2123 466/1263 1 509/936
-365/1372 495/1846 -877/1393 -45/1514 577/1061 509/936 1
[b,bint,r,rint,stats] = regress(y,X)
b =
4550/2113
-141/11156
278/46981
-1307/12782
242/8479
43/6437
-33/510839
bint =
-5545/3392 1521/256
-470/3577 654/6163
-127/7094 121/4069
-455/1929 92/2933
-353/10844 243/2711
-69/19679 218/12925
-31/329808 -18/511289
r =
-3421/3866
-617/868
2035/2677
470/1303
-1739/1083
959/739
451/809
2073/2060
562/6917
-681/1348
-705/1198
-338/8925
-6359/7467
-814/4705
-441/494
-256/1519
-68/9547
338/345
577/636
1605/3376
rint =
-772/351 974/2267
-4545/1706 866/697
-793/713 566/215
-467/475 1529/897
-1999/619 41/2284
-595/1494 1416/473
-1149/1097 3263/1509
-478/593 1508/535
-1166/741 1493/860
-2921/1333 829/702
-2075/839 1269/979
-4886/2351 1588/793
-1096/397 2815/2662
-646/805 755/1654
-1807/739 989/1499
-2976/1345 407/217
-965/1801 133/255
-1094/1501 871/324
-764/829 736/269
-193/146 10066/4429
stats =
948/1327 2997/553 45/8579 4775/5269
mdl=fitlm(XX,y)
mdl =
Linear regression model:
y ~ 1 + x1 + x2 + x3 + x4 + x5 + x6
Estimated Coefficients:
Estimate SE tStat pValue
_________ __________ ________ __________
(Intercept) 2.1533 1.7534 1.2281 0.24119
x1 -0.012639 0.05497 -0.22992 0.82173
x2 0.0059173 0.011026 0.53668 0.60055
x3 -0.10225 0.061851 -1.6532 0.12222
x4 0.028541 0.028279 1.0093 0.33127
x5 0.0066801 0.0047151 1.4167 0.18007
x6 -6.46e-05 1.3606e-05 -4.7478 0.00038094
Number of observations: 20, Error degrees of freedom: 13
Root Mean Squared Error: 0.952
R-squared: 0.714, Adjusted R-Squared: 0.583
F-statistic vs. constant model: 5.42, p-value = 0.00525
mdl1=fitlm(XXX,y)
mdl1 =
Linear regression model:
y ~ 1 + x1 + x2 + x3 + x4 + x5
Estimated Coefficients:
Estimate SE tStat pValue
___________ __________ _______ __________
(Intercept) 2.0947 1.6751 1.2505 0.23161
x1 0.0072028 0.009176 0.78496 0.44556
x2 -0.10046 0.059247 -1.6957 0.11206
x3 0.026708 0.026198 1.0195 0.32528
x4 0.0067589 0.0045408 1.4885 0.1588
x5 -6.3936e-05 1.2839e-05 -4.9798 0.00020193
Number of observations: 20, Error degrees of freedom: 14
Root Mean Squared Error: 0.919
R-squared: 0.713, Adjusted R-Squared: 0.611
F-statistic vs. constant model: 6.96, p-value = 0.00184
mdl2=fitlm(XXXX,y)
mdl2 =
Linear regression model:
y ~ 1 + x1 + x2 + x3 + x4
Estimated Coefficients:
Estimate SE tStat pValue
___________ __________ _______ _________
(Intercept) 1.8295 1.6195 1.1297 0.27636
x1 -0.094087 0.057932 -1.6241 0.12518
x2 0.03224 0.024907 1.2944 0.2151
x3 0.0088885 0.0035943 2.4729 0.025849
x4 -6.6565e-05 1.2235e-05 -5.4407 6.825e-05
Number of observations: 20, Error degrees of freedom: 15
Root Mean Squared Error: 0.907
R-squared: 0.701, Adjusted R-Squared: 0.621
F-statistic vs. constant model: 8.78, p-value = 0.000738
contain0 = (rint(:,1)<0 & rint(:,2)>0);
idx = find(contain0==false)
idx =
0×1 empty double column vector
scatter(y(idx),r(idx),'b','filled')
text(y+dx,r+dy,cellstr(country_abb))
b
b =
4550/2113
-141/11156
278/46981
-1307/12782
242/8479
43/6437
-33/510839
k=["Intercept", "INF","BNK","GOV","SSE","TRD","INIT"]'
"Intercept"
"INF"
"BNK"
"GOV"
"SSE"
"TRD"
"INIT"
Coff.Properties.VariableNames=k';
Coff.Properties.RowNames="Coeff";
Coff
Coff = 1×7 table
| | Intercept | INF | BNK | GOV | SSE | TRD | INIT |
|---|
| 1 Coeff | 4550/2113 | -141/11156 | 278/46981 | -1307/12782 | 242/8479 | 43/6437 | -33/510839 |
|---|
NMMT=movevars(NMMT,8,"Before",1)
NMMT = 20×8 table
| | Country | INF | BNK | GRO | GOV | SSE | TRD | INIT |
|---|
| 1 Argentina | 'Argentina' | 3246/143 | 3857/279 | 747/815 | 3210/217 | 5020/61 | 6560/199 | 204880/11 |
|---|
| 2 Brazil | 'Brazil' | 961/129 | 1496/31 | 2956/2179 | 4070/211 | 5808/73 | 2882/111 | 81180/7 |
|---|
| 3 Chile | 'Chile' | 9377/1079 | 2937/109 | 26875/6891 | 4152/481 | 8451/131 | 10665/206 | 130853/23 |
|---|
| 4 Colombia | 'Colombia' | 563/297 | 24203/194 | 9608/2697 | 3471/248 | 28111/295 | 23511/296 | 206893/9 |
|---|
| 5 Dominican Republic | 'Dominican Republic' | 133/25 | 2160/113 | 1777/2463 | 5003/446 | 28349/403 | 11959/192 | 142265/8 |
|---|
| 6 Egypt, Arab Rep. | 'Egypt, Arab Rep.' | 6081/463 | 11042/277 | 854/229 | 2847/160 | 23780/259 | 22305/424 | 160761/11 |
|---|
| 7 Indonesia | 'Indonesia' | 601/116 | 2116/55 | 693/884 | 841/36 | 12957/148 | 26712/349 | 209776/5 |
|---|
| 8 Israel | 'Israel' | 3758/243 | 1389/35 | 1577/466 | 1559/113 | 94605/1193 | 8843/178 | 92819/6 |
|---|
| 9 Korea, Rep. | 'Korea, Rep.' | 1415/717 | 983/14 | 1477/1012 | 5264/223 | 16342/165 | 15100/219 | 726065/23 |
|---|
| 10 Malaysia | 'Malaysia' | 689/210 | 3332/29 | 6551/2005 | 15555/1256 | 5967/79 | 18272/109 | 318401/20 |
|---|
| 11 Mexico | 'Mexico' | 9167/1950 | 12021/169 | 899/344 | 5362/439 | 15775/182 | 6769/103 | 75609/5 |
|---|
| 12 Panama | 'Panama' | 827/130 | 8201/241 | 13638/5455 | 2153/147 | 9521/129 | 9272/253 | 210074/23 |
|---|
| 13 Peru | 'Peru' | 3557/335 | 4231/109 | 2125/907 | 4699/410 | 21815/271 | 9017/188 | 54213/7 |
|---|
| 14 Russian Federation | 'Russian Federation' | 14996/11397 | 14441/135 | 1360/421 | 578/57 | 7873/79 | 17931/49 | 392074/7 |
|---|
| 15 Saudi Arabia | 'Saudi Arabia' | 1533/230 | 4501/66 | 1027/839 | 1853/94 | 50669/754 | 31347/532 | 70622/7 |
|---|
| 16 Singapore | 'Singapore' | 1929/250 | 6368/207 | 257/107 | 1635/127 | 6788/89 | 12935/261 | 132961/10 |
|---|
| 17 South Africa | 'South Africa' | 2955/664 | 8617/145 | -2017/1192 | 1996/197 | 12231/136 | 9881/69 | 819959/8 |
|---|
| 18 Turkey | 'Turkey' | 5135/1766 | 8392/109 | 419/104 | 2177/174 | 6107/95 | 16330/127 | 159616/11 |
|---|
| 19 United Arab Emirates | 'United Arab Emirates' | 2046/233 | 6616/275 | 2476/677 | 21827/2240 | 21137/344 | 2825/46 | 65255/7 |
|---|
| 20 Uruguay | 'Uruguay' | 1618/557 | 251/8 | 1192/329 | 3043/261 | 11093/148 | 6424/137 | 160562/25 |
|---|
%writetable(NMMT,'data_col.xlsx')
% tm=join(["Country",num2str(i),".xlsx"]);
% writetable(table{i},tm)
Brief summary of this function.
It uses the 2D newton method to compute the solution of a system of 2 equations
Detailed explanation of this function.
f1,f2 are the two @functions of the system given in their implicit form
x0 is a 2X1 array which contains the initial guess
MaxIter contains the max number of iterations
tol is the tolerance error
function x = Newton_multi(f1,f2,x0,MaxIter,tol)
%Computing partial derivvatives approximations
J(1,1)=(f1(x1+h,x2)-f1(x1,x2))/h;
J(2,1)=(f2(x1+h,x2)-f2(x1,x2))/h;
J(1,2)=(f1(x1,x2+h)-f1(x1,x2))/h;
J(2,2)=(f2(x1,x2+h)-f2(x1,x2))/h;
invJ=[J(2,2) -J(1,2);-J(2,1) J(1,1)]./(J(1,1)*(J(2,2))-J(1,2)*J(2,1));
while it<MaxIter && (abs(f2(x(1),x(2))-x(2))>tol || abs(f1(x(1),x(2))-x(1))>tol)
x=x-invJ*[f1(x(1),x(2));f2(x(1),x(2))];
%inverse jacobi update at x
J(1,1)=(f1(x1+h,x2)-f1(x1,x2))/h;
J(2,1)=(f2(x1+h,x2)-f2(x1,x2))/h;
J(1,2)=(f1(x1,x2+h)-f1(x1,x2))/h;
J(2,2)=(f2(x1,x2+h)-f2(x1,x2))/h;
invJ=[J(2,2) -J(1,2);-J(2,1) J(1,1)]./(J(1,1)*(J(2,2))-J(1,2)*J(2,1));
function MP=marginal_profit(quantity,C,w,D)
P(quantity)=D(sum(w))*quantity-C(quantity);